package com.jrauto.CarAppBackend.config;

import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;

/**
 * @author : huiMing
 * Date : 2025年06月23日 16:37
 * @version V1.0
 */
@OpenAPIDefinition(
        info = @Info(
                title = "车辆平台API文档,，涵盖车辆信息上报、媒体上传、后台管理等功能。",
                version = "1.0.0",
                description = "uniapp请求接口文档",
                termsOfService = "https://jrauto.example.com/terms",
                contact = @Contact(
                        name = "jrauto",
                        email = "support@jrauto.com",
                        url = "https://jrauto.com"
                ),
                license = @License(
                name = "Apache 2.0",
                url = "https://www.apache.org/licenses/LICENSE-2.0"
        )
        ),
        security = @SecurityRequirement(name = "JWT"),
        externalDocs = @ExternalDocumentation(description = "参考文档",
                url = "https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations"
        )
)
@SecurityScheme(type = SecuritySchemeType.HTTP, name = "JWT", scheme = "bearer", in = SecuritySchemeIn.HEADER)
public class Swagger3Config {

    @Bean
    public GroupedOpenApi carApi() {
        return GroupedOpenApi.builder()
                .group("前端App")
                .pathsToMatch("/car/**")
                .build();
    }

    @Bean
    public GroupedOpenApi adminApi() {
        return GroupedOpenApi.builder()
                .group("后台管理")
                .pathsToMatch("/admin/**")
                .build();
    }
}